<template>
  <el-dialog
    title="退款"
    :visible.sync="visible"
    width="400px"
    :before-close="
      () => {
        $emit('close');
      }
    "
  >
    <div style="margin-bottom:10px;">
      金额：<el-input v-model="money" type="number"> </el-input>
    </div>
    <div>
      备注：
      <el-input v-model="reply" type="textarea" resize="none" rows="6">
      </el-input>
    </div>
    <span slot="footer" class="dialog-footer">
      <el-button @click="$emit('close')">取 消</el-button>
      <el-button type="primary" @click="refundOrder">确 定</el-button>
    </span>
  </el-dialog>
</template>

<script>
import { refundOrder } from "@/api/order-mng";
export default {
  props: ["visible", "order", "status"],
  data() {
    return {
      reply: null,
      money: null
    };
  },
  watch: {
    visible: function(val) {
      if (val) {
      } else {
        this.reply = null;
        this.money = null;
      }
    }
  },
  methods: {
    refundOrder() {
      if (!this.money) {
        this.$message({
          message: "请填写退款金额",
          type: "warning"
        });
        return;
      }
      refundOrder({
        order_no: this.order.after.order_no,
        remark: this.reply,
        money: this.money,
        id: this.order.id
      }).then(res => {
        if (res.code === 200) {
          this.$message({
            message: "操作成功",
            type: "success"
          });
          this.$emit("close");
        }
      });
    }
  },
  created() {}
};
</script>

<style lang="scss" scoped></style>
